﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObjects;
using DataObjects;
using DataObjects.Interfaces;
using Service.DataTransferObjects;

namespace Service
{
    public class OrderService
    {
        private static readonly ICustomerDao CustomerDao = DataAccess.CustomerDao;
        private static readonly IOrderDao OrderDao = DataAccess.OrderDao;

        public void SetOrder(OrderDTO order)
        {
            Customer customer = CustomerDao.GetCustomer(order.CustomerId);
            
            if (!customer.IsAllowedDiscount())
            {
                order.Discount = 0;
            }

            OrderDao.InsertOrder(Mapper.FromDataTransferObject(order));
        }
    }
}
